package com.fosu.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Desription
 * 缩略图dao
 * @author manno
 * @date 2020/11/10
 */
@Mapper
@Repository
public interface CompressImgDao
{
    /**
     * 根据首页用户传入的商品id获得缩略图图片组
     * @param productId 商品id
     * @return List<String> 缩略图图片组的url字串集合
     */
    @Results(id = "imgMap", value = {
            @Result(property = "compressImg", column = "compress_img")
    })
    @Select("select compress_img " +
            "from product_compressimg " +
            "where product_id=#{productId}")
    List<String> findImgsById(int productId);
    /**
     * 插入缩略图url
     * @param productId 商品id
     * @param compressImg 要插入的缩略图url
     */
    @Insert("insert into product_compressimg(product_id,compress_img) values(#{productId},#{compressImg})")
    void save(int productId,String compressImg);

    /**
     * 清除所有与商品有关的缩略图url
     * @param productId 商品id
     */
    @Delete("delete from product_compressimg where product_id=#{productId}")
    void clean(int productId);
}
